#pragma once
///////////////////////////////////////////////////////////////////////////////
// Project: Hoyo Client Game
//
// hy_function.h
// Created: 2012-8-6
// Author: Like Cheng
///////////////////////////////////////////////////////////////////////////////

#include "hy_stddef.h"

#ifndef __HY_FUNCTION_H__
#define __HY_FUNCTION_H__


NS_HY_BEGIN
#define				HY_FUNC			hy_function::instance()
class HY_DLL hy_function
{
public:

	static hy_function*			instance();
	static void					purge_instance();

	//					COMMON_FUNC->gb2312_to_uft8( menuItemStr, "gb2312", "utf-8" );
	int						form_code( std::string &in_str, std::string &out_str ,const char* toCode,const char* formCode );

	bool					gb2312_to_utf8(  const char* in_str, std::string &out_str );
	bool					utf8_to_gb2312( const char* in_str, std::string &out_str );
	std::string				gb2312_to_utf8( const char* in_str );
	std::string				utf8_to_gb2312( const char* in_str );

	void					unicode_to_utf8( char* out, wchar_t* ptext);
	void					utf8_to_unicode( wchar_t* pout, char *ptext );

	static std::string		hy_vsprintf( const char* msg, ... );
	static void				hy_vsprintf( std::string &temp, const char* msg, ... );

	uint					hash_bytes( const char* begin, const char* end, uint accum );
	uint					hash_bytes_icase( const char* begin, const char* end, uint accum );
	uint					string_to_key( const char *str, ubool forceLower = hy_false );

	ubool					check_path_file_path_ok( const char* path_file );
	ubool					check_path_file_name_ok( const char* path_name );

	ubool					is_num( const char* in_str );
	ubool					splite_string_to_vec( const char* in_str, std::vector< std::string > &out_str, char sign = '|' );
	ubool					splite_sint_to_vec( const char* in_str,std::vector< sint > &out_int, char sign = '|' );
	int						get_str_pos( const char* in_str, const char* str, char sign = '|' );

	int						string_to_int( const char* str );
	std::string				int_to_string( int int_a );

	ubool					assembly_vec_by_string( std::vector< std::string > input_str, std::string &out_str, char sign = '|' );
	ubool					assembly_vec_by_sint( std::vector< int > input_str, std::string &out_str, char sign = '|' );				

private:

	static hy_function*			instance_p_;
};
NS_HY_END

#endif